package com.wtz.temptest;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Date: 2020/9/23
 * Company: www.dtstack.com
 *
 * @author tiezhu
 */
public class TempDemoTwo {
    public static void main(String[] args) {
        String key = "a";
        Map<String, String> tempMap = new HashMap<>(8);
        tempMap.put("a", "b");
        tempMap.put("b", "c");
        tempMap.put("c", "d");
        tempMap.put("d", "e");

        while (tempMap.containsKey(key)) {
            key = tempMap.get(key);
        }
        System.out.println(key);

        if (checkContainIterationTableName(key, tempMap)) {
            System.out.println(tempMap.get(key));
        }
    }

    private static boolean checkContainIterationTableName(String checkTableName, Map<String, String> mappingTableName) {
        for (int i = 0; i < mappingTableName.size() + 1; i++) {

            checkTableName = mappingTableName.get(checkTableName);
            if (checkTableName == null) {
                return false;
            }
        }
        return true;
    }
}
